/**
 * This class represents a user
 */

/**
 * @author Maximilian Csuk
 * @author Bernhard Denner
 * @author Konrad Paumann
 *
 * $Revision$
 * $Date$
 */
import java.util.*;

public class User {
	/**
	 * variables
	 */
	private String name;
	private String password;
	
	// permission variables:
	private final static int WHMASK = 	0x000011;
	public final static int WHNONE = 	0x000000;
	public final static int WHREAD = 	0x000001;
	public final static int WHWRITE = 	0x000010;
	
	private final static int PGMASK = 	0x001100;
	public final static int PGNONE = 	0x000000;
	public final static int PGREAD = 	0x000100;
	public final static int PGWRITE = 	0x001000;
	
	private final static int PMASK = 	0x001100;
	public final static int PNONE = 	0x000000;
	public final static int PREAD = 	0x000100;
	public final static int PWRITE = 	0x001000;
	
	private int permissions;
	
	/**
	 * constructor
	 * @param name username
	 * @param password password
	 * @param permissions - see variables
	 */
	public User(String name, String password, int permissions) {
		this.name = name;
		this.password = password;
		this.permissions = permissions;
	}
	
	public String getName() {
		return name;
	}
	/**
	 * checks if user can read warehouse
	 * @return boolean
	 */
	public boolean canReadWarehouse() {
		return (permissions & WHREAD) != 0;
	}
	/**
	 * checks if user can write in warehouse
	 * @return boolean
	 */
	public boolean canWriteWarehouse() {
		return (permissions & WHWRITE) != 0;
	}
	/**
	 * checks if user can read a product group
	 * @return boolean
	 */
	public boolean canReadProductGroup() {
		return (permissions & PGREAD) != 0;
	}
	/**
	 * checks if user can write in a product group
	 * @return boolean
	 */
	public boolean canWriteProductGroup() {
		return (permissions & PGWRITE) != 0;
	}
	/**
	 * checks if user has read rights to a product
	 * @return boolean
	 */
	public boolean canReadProduct() {
		return (permissions & PREAD) != 0;
	}
	/**
	 * checks if user has write rights to a product
	 * @return boolean
	 */
	public boolean canWriteProduct() {
		return (permissions & PWRITE) != 0;
	}
}
